/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年1月21日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @Type ChessFlyWeightFactory
 * @Desc 享元工厂
 * @author 52489
 * @date 2019年1月21日
 * @Version V1.0
 */
public class ChessFlyWeightFactory {
    // 享元池
    private static Map<String, ChessFlyWeight> map = new HashMap<>();

    public static ChessFlyWeight getChess(String color) {
        if (map.get(color) != null) {
            return map.get(color);
        } else {
            ChessFlyWeight chessFlyWeight = new ConcreteChess(color);
            map.put(color, chessFlyWeight);
            return chessFlyWeight;
        }
    }

}
